<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body{
            text-align: center;
        }
    </style>
</head>
<body>

</body>
<script>
    function yhsj(hangs) {
        var outArr =[];
        for(var i=0;i<hangs;i++){
            var innerArr =[];
            for(var j=0;j<(i+1);j++){
                innerArr[j]=0;
            }
            outArr[i]=innerArr;
        }

        for(var a=0;a<outArr.length;a++){
            for(var b=0;b<outArr[a].length;b++ ){
                outArr[a][0] = outArr[a][outArr[a].length-1]=1;
                if(a>1 && b>0 && b< outArr[a].length-1){
                    outArr[a][b] =  outArr[a-1][b] + outArr[a-1][b-1]
                }
            }
        }

        for(var i=0;i<outArr.length;i++){
            for(var j=0;j<outArr[i].length;j++){
                document.write(outArr[i][j]+"&nbsp;&nbsp;")
            }
            document.write("<br/>")
        }
    }
    yhsj(10)
</script>
</html>